﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class SkySunManager : MonoBehaviour
{
    // Start is called before the first frame update

    

    private float skySunPosY = 6;//阳光生成的初始纵坐标

    private float skySunMaxPosX = 4;
    private float skySunMinPosX = -6;
    //阳光生成的随机横坐标

    private float sunDownMaxPosY = 1;
    private float sunDownMinPosY = -3.7F;
    //阳光落地的Y轴范围

    void Start()
    {
        
        InvokeRepeating("Create", 5, 10);//随机生成阳光指令
    }

    // Update is called once per frame
    void Update()
    {

    }
    //随机生成阳光
    void Create()
    {
        Sunlight sun = GameObject.Instantiate<GameObject>(GameManager.Instance.GameConf.Sun,Vector3.zero, Quaternion.identity, transform).GetComponent<Sunlight>();
        float downY = Random.Range(sunDownMinPosY, sunDownMaxPosY);//阳光下落终点的纵坐标值
        float createX = Random.Range(skySunMinPosX, skySunMaxPosX);//阳光生成的横坐标值
        sun.InitForSky(downY, createX, skySunPosY);

    }
}
